<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

</body>
</html>
<script>
    var arr={name:'李晨阳',age:18,aihao:['看电视','玩手机']}
    function coparr(arr) {
        var arr2=Array.isArray(arr)?[]:{}
      for (var key in arr) {
      if(typeof arr[key]=='object'){
            arr2[key]=coparr(arr[key])
      }
        else{
            arr2[key]=arr[key]
        }
      }
      return arr2
    }
    arr2=coparr(arr)
    console.log(arr);
    console.log(arr2);
</script>